﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using LeeAnn.Framework;

namespace LeeAnn.FeedForward
{
    public class FeedForwardNeuronPlaceholder: NeuronPlaceholder
    {
        //Keeps track of the index number, so we don't have to keep iterating over all the neurons
        private int nnum = -1;

        public FeedForwardNeuronPlaceholder(Position3D Pos)
        {
            Position = Pos;
            nType = NeuronType.Normal;
        }

        override
        public int getNeuron(AnnFramework framework)
        {
            if (nnum == -1)
            {
                if (nType == NeuronType.Input || nType == NeuronType.Output)
                {
                    for (int i = 0; i < framework.InputOutputNeurons.Count; i++)
                    {
                        if (framework.InputOutputNeurons[i].Position.Equals(Position))
                        {
                            nnum = i;
                            break;
                        }
                    }
                }
                else
                {
                    for (int i = 0; i < framework.Neurons.Count; i++)
                    {
                        if (framework.Neurons[i].Position.Equals(Position))
                        {
                            nnum = i;
                            break;
                        }
                    }
                }
            }
            return nnum;

        }
    }
}
